package com.demo.jhfkd;

import com.demo.common.model.Jhfkd;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * 本 demo 仅表达最为粗浅的 jfinal 用法，更为有价值的实用的企业级用法 详见 JFinal 俱乐部: http://jfinal.com/club
 * 
 * JhfkdValidator.
 */
public class JhfkdValidator extends Validator {

	@Override
	protected void validate(Controller controller) {
		validateRequiredString("jhfkd.title", "titleMsg", "请输入Jhfkd标题!");
		validateRequiredString("jhfkd.content", "contentMsg", "请输入Jhfkd内容!");
	}

	@Override
	protected void handleError(Controller controller) {
		controller.keepModel(Jhfkd.class);

		String actionKey = getActionKey();
		if ("/jhfkd/save".equals(actionKey)) {
			controller.render("add.html");
		} else if ("/jhfkd/update".equals(actionKey)) {
			controller.render("edit.html");
		}
	}
}
